<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ page import="com.hmsm.sys.po.UserInfo"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.text.SimpleDateFormat"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
	String userName = "";
	String userDept = "";
	UserInfo user = (UserInfo) session.getAttribute("user");
	if(user != null) {
		userName = user.getUserName();
		userDept = user.getUserDept();;
	} else {
		response.sendRedirect(basePath + "/page/error.jsp");
	}

	Date date = new Date();
	String dateStr = "";
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	dateStr = sdf.format(date);
%>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>发布系统消息</title>
	<link type="text/css" rel="stylesheet" href="<%=basePath%><s:property value="#session.themeStyle.mainCss" default="Skin/PM/LightBlue/main.css"/>" />
	<script src="<%=basePath%>js/jquery.js" type="text/javascript"></script>
	<script src="<%=basePath%>js/store.js" type="text/javascript"></script>
	<style type="text/css">
		
		td {
			height: 40px;
		}
		
		li {
			width: 230px
		}
	</style>
	<script type="text/javascript">
		
		function save() {
			$("#message").text("");
			var mid = $("#mid").val();
			var customerName = $.trim($("#customerName").text());
			var title = $("#title").val();
			var currentUnit = $("#currentUnit").text();
		
			if (title == '') {
				$("#message").text("请填写消息标题！");
				return;
			}
			//获取内容
			var content = $("#content").val();
			if (content == '') {
				$("#message").text("请填写消息内容！");
				return;
			}
			if (content.length>500) {
				$("#message").text("内容长度为（"+content.length+"）字，不能超过500字！");
				return;
			}
			//日期
			var bdate = $("#bdate").text();
			//保存消息
			var url = $("form")[0].action;
			var from = $("form")[0];
			from.submit();
		}
	</script>
</head>
<body>
	<div style="margin-left: 8px; margin-right: 8px; border-bottom: 2px #3497cf solid; height: 24px; margin-top: 0px; line-height: 24px;">
		当前位置：系统管理&gt;&gt;消息管理
	</div>
	<s:form action="sysMessage-save.action" theme="simple">
	<center>
		<div class="editBlock" style="margin-left: 8px; margin-right: 8px; margin-top: 8px;">
			<table>
				<tbody>
					<tr style="height: 50px;">
						<th colspan="2" style="text-align: center; font-weight: bold; font-size: 16px; background-color: #3497cf; color: white;">
							消息发布
						</th>
					</tr>
					<tr>
						<th style="width:20%">
							<strong style="color: #000000;">标题：</strong>
						</th>
						<td style="text-align: left">
							<input id="mid" type="hidden" name="mid" value="<s:property value="sysMessagePublish.pkId"/>" />
							<input style="width: 340px; height: 25px; margin-left: 5px;" class="inputText" id="title" name="title" type="text" value="<s:property value="sysMessagePublish.title"/>" maxlength='40' size='40' />
						</td>
					</tr>
					<tr>
						<th>
							<strong style="color: #000000;">内容：</strong>
						</th>
						<td style="text-align: left; width:460px;">
							<div style="text-align: left; float: left">
								<textarea id="content" name="content" style="list-style-type: none; margin-left: 5px; border: #3497cf 1px solid; height: 100px; width: 340px; overflow-y: scroll;color:black;"><s:property value="sysMessagePublish.content"/></textarea>
							</div>
						</td>
					</tr>
					<tr>
						<th>
							<strong style="color: #000000;">所属部门：</strong>
						</th>
						<td id="currentUnit" style="text-align: left;">
							<s:property value="#session.user.depart.name"/>
						</td>
					</tr>
					<tr>
						<th>
							<strong style="color: #000000;">发布人：</strong>
						</th>
						<td id="customerName" style="text-align: left;"><input style="width: 340px; height: 25px; margin-left: 5px;" class="inputText" id="creater" name="creater" type="text" value="<s:property value="#session.user.name"/>" maxlength='40' size='40' /></td>
					</tr>
					<tr>
						<th>
							<strong style="color: #000000;">发布日期：</strong>
						</th>
						<td id="bdate" style="text-align: left;"><%=dateStr%></td>
					</tr>
					<tr style="color: red;">
						<th>
							<strong style="color: #000000;">提示：</strong>
						</th>
						<td id="message" style="text-align: left;">
							<s:property value="message" />
						</td>
					</tr>
				</tbody>
			</table>
		</div>
		<div class="toolbar" style="text-align: center;">
			<a class="but39" onClick="save()" style="text-decoration: none;"><s:if test="sysMessagePublish.pkId==null">发布</s:if><s:else>保存</s:else></a>
			<a class="but39" onclick="history.back();" style="text-decoration:none;">返回</a>
		</div>
		<input type="hidden" id="customerJson" value="">
	</center>
	</s:form>
</body>
</html>